<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑评论</title>
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
    <form class="layui-form" action="">
        <textarea id="L_content" name="content" required lay-verify="required" placeholder="{:lang('please input the content')}" class="layui-textarea fly-editor taonyeditor">{$comment.content}</textarea>
        <div class="bottom">
            <div class="button-container">
                <input type="text" name="id" value="{$comment.id}" class="layui-input layui-hide"/>
                <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="comment-save">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button type="reset" class="pear-btn pear-btn-sm">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </div>
    </form>
    <script src="/static/jquery-3.6.0.min.js"></script>
    <script src="/layui-1/layui.js"></script>

    {:hook('taonyeditor')}

    <script>
      let taonystatus = "{:hook('taonystatus') ? 1 : 0} ";
      layui.config({
          version: "3.0.0"
          ,base: "/static/res/mods/"
      }).use(function () {
        var $ = layui.jquery,
          form = layui.form;

        // 发布文章
        form.on("submit(comment-save)", function (data) {
          var loading = layer.load(1);
          $.ajax({
            type: "post",
            url: "{:url('comment/edit')}",
            data: data.field,
            dataType: "json",
            success: function (res) {
                layer.close(loading);
                  if (res.code === 0) {
                      layer.msg(res.msg, {
                          icon: 1,
                          time: 1000
                      }, function() {
                          var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                          parent.location.reload(); //刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
                          parent.layer.close(index); //再执行关闭
                      });
                  } else {
                    notify.error(data.msg);
                }
            },
          });
          return false;
        });

      });
    </script>
</body>
</html>
